package com.wenson.behavior.mediator;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: ChatRoom
 * @Author: luowangcheng
 * @Date: 2024/6/16 9:35
 * @Description:
 */
public class ChatRoom {
    private String name;

    public ChatRoom(String name) {
        this.name = name;
    }

    List<User> users = new ArrayList<>();

    public void register(User user) {
        this.users.add(user);
        System.out.print("系统消息：欢迎【");
        System.out.print(user.getName());
        System.out.println("】加入聊天室【" + this.name + "】");
    }

    public void sendMsg(User fromWhom, String msg){
//        users.forEach(toWhom -> toWhom.listen(fromWhom, msg));
    }
}
